package org.one;

import com.lmax.disruptor.YieldingWaitStrategy;
import com.lmax.disruptor.dsl.ProducerType;
import org.one.disruptor.MessageConsumer;
import org.one.disruptor.RingBufferWorkerPoolFactory;
import org.one.onecat.OneCatMessageConsumer;
import org.one.onecat.OneCatServer;

/**
 * @Classname : OneCat
 * @Description : 启动服务器
 * @Author : cty
 * @Date 2023/6/11 23:25
 */


public class OneCatApplication {
    public static void run(String[] args) throws Exception {
        // 初始化disruptor队列
        MessageConsumer[] conusmers = new MessageConsumer[8];
        for(int i =0; i < conusmers.length; i++) {
            MessageConsumer messageConsumer = new OneCatMessageConsumer("onecat:consumer:" + i);
            conusmers[i] = messageConsumer;
        }
        RingBufferWorkerPoolFactory.getInstance().initAndStart(ProducerType.MULTI,
                1024*1024,
                new YieldingWaitStrategy(),
                //new BlockingWaitStrategy(),
                conusmers);

        // 启动onecat服务器
        OneCatServer server = new OneCatServer("org.one.webapp");
        server.start();
    }

    public static void main(String[] args) throws Exception {
        OneCatApplication.run(args);
    }
}
